home *** CD-ROM | disk | FTP | other *** search
/ Mission 3 / Mission 3.zip / Mission 3.iso / texte / qed / src / poslist.c < prev    next >
C/C++ Source or Header  |  1998-11-06  |  2KB  |  127 lines

  1. /*
  2.  * poslist.c
  3.  * Liste, die Dateinamen mit Cursorposition speichert.
  4. */
  5. #include <support.h>
  6.  
  7. #include "global.h"
  8. #include "comm.h"
  9. #include "edit.h"
  10. #include "find.h"
  11. #include "icon.h"
  12. #include "projekt.h"
  13. #include "window.h"
  14. #include "poslist.h"
  15.  
  16.  
  17. void insert_poslist(POSENTRY **list, char *n1, int x, long y)
  18. {
  19.     POSENTRY    *new, *p;
  20.     PATH        name;
  21.     
  22.     if (strchr(n1, '/') != NULL)                /* UNIX-Pfad -> nach TOS wandeln */
  23.         unx2dos(n1, name);
  24.     else
  25.         strcpy(name, n1);
  26.  
  27.     p = find_poslist(*list, name, NULL, NULL);
  28.     if (p != NULL)                    /* schon 'drin -> nur Position updaten */
  29.     {
  30.         p->zeile = y;
  31.         p->spalte = x;
  32. /*
  33. debug("insert_poslist: %s, x= %d, y= %ld: update\n", p->filename, p->spalte, p->zeile);
  34. */
  35.     }
  36.     else                                /* neuer Eintrag */
  37.     {    
  38.         new = (POSENTRY*) malloc(sizeof(POSENTRY));
  39.         new->next = NULL;
  40.         if (*list == NULL)
  41.             *list = new;
  42.         else
  43.         {
  44.             p = *list;
  45.             while (p->next != NULL)
  46.                 p = p->next;
  47.             p->next = new;
  48.         }
  49.         new->next = NULL;
  50.         strcpy(new->filename, name);
  51.         make_normalpath(new->filename);
  52.         new->spalte = x;
  53.         new->zeile = y;
  54. /*
  55. debug("insert_poslist: %s, x= %d, y= %ld: new\n", new->filename, new->spalte, new->zeile);
  56. */
  57.     }
  58. }
  59.  
  60.  
  61. void open_poslist(POSENTRY *list)
  62. {
  63.     int        icon;
  64.     POSENTRY    *p;
  65.     
  66.     p = list;
  67.     while (p != NULL)
  68.     {
  69. /*
  70. debug("open_poslist: %s, x= %d, y= %ld\n", p->filename, p->spalte, p->zeile);
  71. */
  72.         if (!shift_pressed() && filematch(p->filename, "*.QPJ", -1))
  73.             icon = load_projekt(p->filename);
  74.         else
  75.         {
  76.             icon = load_edit(p->filename, FALSE);
  77.             if (icon >= 0)
  78.             {
  79.                 desire_x = 0;
  80.                 if (p->spalte > 0)
  81.                     desire_x = p->spalte;
  82.                 desire_y = 0;
  83.                 if (p->zeile > 0)
  84.                     desire_y = p->zeile;
  85.                 if (desire_x || desire_y)
  86.                     icon_edit(icon, DO_GOTO);
  87.             }
  88.         }
  89.         if (icon > 0)
  90.             send_dhst(p->filename);
  91.         p = p->next;
  92.     }
  93. }
  94.  
  95.  
  96. void delete_poslist(POSENTRY **list)
  97. {
  98.     POSENTRY    *p1, *p2;
  99.     
  100.     p1 = *list;
  101.     while (p1 != NULL)
  102.     {
  103.         p2 = p1->next;
  104.         free(p1);
  105.         p1 = p2;
  106.     }
  107.     *list = NULL;
  108. }
  109.  
  110.  
  111. POSENTRY *find_poslist(POSENTRY *list, char *name, int *x, long *y)
  112. {
  113.     POSENTRY    *p;
  114.  
  115.     p = list;
  116.     while ((p != NULL) && (strcmp(p->filename, name) != 0))
  117.         p = p->next;
  118.     if (p)
  119.     {
  120.         if (x != NULL)
  121.             *x = p->spalte;
  122.         if (y != NULL)
  123.             *y = p->zeile;
  124.     }
  125.     return p;
  126. }
  127.